package elephant.rpc.network.netty;

import elephant.rpc.server.core.RPCChannel;
import io.netty.channel.Channel;

/**
 * 
 * @author skydu
 *
 */
public class NettyChannel implements RPCChannel{

	private Channel channel;
	
	public NettyChannel(Channel channel){
		this.channel=channel;
	}
	//
	@Override
	public void write(Object message) {
		channel.writeAndFlush(message);
	}
	
	@Override
	public boolean isConnected() {
		if(channel==null){
			return false;
		}
		return channel.isActive();
	}
	
	@Override
	public void disconnect() {
		if(channel==null){
			return;
		}
		channel.disconnect();
	}

}
